<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    //以斜杠开始的相对路径找资源是以服务器路径为准，需要加上工程路径
request.setAttribute("s_path",request.getContextPath());
%>
<head>
    <title>员工列表</title>
    <script type="text/javascript" src="${s_path}/static/js/jquery-1.12.4.min.js"></script>
    <link rel="stylesheet" href="${s_path}/static/bootstrap-3.4.1-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="${s_path}/static/bootstrap-3.4.1-dist/js/bootstrap.min.js">
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12 col-md-offset-1">
            <h1>SSM-CRUD</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 col-md-offset-9">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <table class="table table-hover">
                <tr>
                    <th>#</th>
                    <th>lastName</th>
                    <th>email</th>
                    <th>gender</th>
                    <th>deptName</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="emp">
                <tr>
                    <th>${emp.id}</th>
                    <th>${emp.lastName}</th>
                    <th>${emp.email}</th>
                    <th>${emp.gender==0?'男':'女'}</th>
                    <th>${emp.dept.deptName}</th>
                    <th>
                        <button class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            编辑
                        </button>
                        <button class="btn btn-danger btn-sm">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                            删除
                        </button>
                    </th>
                </tr>
                </c:forEach>
            </table>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-1">
            当前第
            <span class="label label-default">${pageInfo.pageNum}</span>
            页，共有
            <span class="label label-default">${pageInfo.pages}</span>
            页，总计
            <span class="label label-default">${pageInfo.total}</span>
            条记录
        </div>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li><a href="${s_path}/emps?pn=1">首页</a></li>
                    <c:if test="${pageInfo.pageNum>1&&pageInfo.pageNum<=pageInfo.pages}">
                        <li>
                            <a href="${s_path}/emps?pn=${pageInfo.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach items="${pageInfo.navigatepageNums}" var="pn">
                        <c:if test="${pn==pageInfo.pageNum}">
                            <li class="active"><a href="#">${pn}</a></li>
                        </c:if>
                        <c:if test="${pn!=pageInfo.pageNum}">
                            <li><a href="${s_path}/emps?pn=${pn}">${pn}</a></li>
                        </c:if>
                    </c:forEach>

                    <c:if test="${pageInfo.pageNum>=1&&pageInfo.pageNum<pageInfo.pages}">
                        <li>
                            <a href="${s_path}/emps?pn=${pageInfo.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <li><a href="${s_path}/emps?pn=${pageInfo.pages}">尾页</a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
